package com.mnnu.controller;

import com.mnnu.common.controller.BaseController;
import com.mnnu.common.domain.AjaxResult;
import com.mnnu.common.domain.entity.SysDept;
import com.mnnu.common.domain.entity.SysUser;
import com.mnnu.common.page.TableDataInfo;
import com.mnnu.system.service.ISysDeptService;
import com.mnnu.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/system/user")
public class SysUserController extends BaseController {

    @Autowired
    public ISysUserService sysUserService;
    @Autowired
    public ISysDeptService sysDeptService;

    /**
     * 分页查询用户信息
     * @param user
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(SysUser user) {
        // 开启分页
        startPage();
        // 业务查询
        List<SysUser> list = sysUserService.list(user);
        return getDataTable(list);
    }

    /**
     * 查询部门下拉树
     * @param dept
     * @return
     */
    @GetMapping("/deptTree")
    public AjaxResult selectDeptTree(SysDept dept) {
        return success(sysDeptService.getDeptTreeSelect(dept));
    }
}
